import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class fileOpenCommand extends JMenuItem implements Command {
    private JFileChooser fileChooser;
    private JPanel panel;
   
    public fileOpenCommand(JPanel panel)
    {
        this.panel=panel;
        this.fileChooser=new JFileChooser();
    }
    public void execute()
    {
        panel.setBackground(Color.WHITE);

        final JFileChooser Dialogul = new JFileChooser();
    	Dialogul.setCurrentDirectory(new File("."));
        

		if (Dialogul.showOpenDialog(fileOpenCommand.this)!=JFileChooser.APPROVE_OPTION)
			return;
		Thread fir = new Thread()
		{
			public void run()
			{
				File fisier = Dialogul.getSelectedFile();
				try
				{
					FileReader intrare = new FileReader (fisier);
				//	Text.read(intrare, null);
					intrare.close();
				}
				catch(IOException ex)
				{
					ex.printStackTrace();
				}
			}
		};
		fir.start();  
        
    } 

}
